<template>
    <div>
        <h3>门店列表</h3>
        门店名称:<input type="text" v-model="info.mname">
        行业分类:<select name="" id="" v-model="info.sid">
                        <option value="">请选择</option>
                        <option :value="item.sid" v-for="item in dataa">{{item.sname}}</option>
                </select>
          <input type="button" value="查询" @click="ok">
        <table border="1">
            <tbody>
                <tr>
                    <td>门店名称</td>
                    <td>状态</td>
                    <td>所在城市</td>
                    <td>图片</td>
                    <td>行业分类</td>
                    <td>操作</td>
                </tr>

                <tr v-for="item in data">
                    <td>{{item.mname}}</td>
                    <td>{{item.data}}</td>
                    <td>{{item.react}}</td>
                    <td><img :src="item.imger" height="50" width="50"></td>
                    <td>{{item.sname}}</td>
                    <td><input type="button" value="删除" class="btn btn-danger" @click="del(item.id)"></td>
                </tr>

            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref,reactive,onMounted } from 'vue';
import axios from 'axios';
import moment from 'moment';
import { useRoute,useRouter } from 'vue-router';

const route=useRoute();
const router=useRouter();

let info:any=reactive({
    mname:'',
    sid:'',
});

let data:any=ref([]);

let dataa:any=ref([]);

onMounted(()=>{
    bind();
    ok();
})
const ok=(()=>{
    axios({
        url:'/api/Reat/Showu',
        method:'get',
        data:info,
    })
    .then((res)=>{
        console.log(res);
        data.value=res.data;
        // console.log(res);
        // data.value=res.data;
    })
    .catch((err)=>{
        console.log(err);
    })
})

const del=(id:any)=>{
    //1.友好提示 //2.发送请求//3.刷新列表
    let f=confirm("请问您确定要删除吗?")
    if(f)
    {
        //2.发送请求
        axios({
            url:'/api/Reat/dele',
            method:'delete',
            params:{
                id:id
            }
        })
        .then((res)=>{
            console.log(res);
            if(res.data>0)
            {
                alert("删除成功");
                ok();
                return;
            }
            else
            {
                alert("删除失败");
                return;
            }
        })
        .catch((err)=>{
            console.log(err);
        })
    }
}

const bind=(()=>{
    axios({
        url:'/api/Reat/Bind',
        method:'get',
    })
    .then((res)=>{
        console.log(res);
        dataa.value=res.data;
    })
    .catch((err)=>{
        console.log(err);
    })
})
</script>

<style scoped>

</style>